package com.test.springai.config;

import com.alibaba.cloud.ai.memory.redis.LettuceRedisChatMemoryRepository;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created with IntelliJ IDEA.
 *
 * @description:
 * @author: liuziyang
 * @since: 9/5/25 4:32 PM
 * @modifiedBy:
 * @version: 1.0
 */
@Configuration
public class RedisMemoryConfig {

  @Value("${spring.ai.memory.redis.host}")
  private String redisHost;

  @Value("${spring.ai.memory.redis.port}")
  private int redisPort;

  @Value("${spring.ai.memory.redis.password}")
  private String redisPassword;

  @Value("${spring.ai.memory.redis.timeout}")
  private int redisTimeout;

  @Bean
  public LettuceRedisChatMemoryRepository redisChatMemoryRepository() {
    return LettuceRedisChatMemoryRepository.builder()
        .host(redisHost)
        .port(redisPort)
        .timeout(redisTimeout)
        .build();
  }
}
